//
//  FWGuideView.m
//  BirdLoveSheep
//
//  Created by wwj on 16/3/15.
//  Copyright © 2016年 wwj. All rights reserved.
//

#import "FWGuideView.h"

@implementation FWGuideView

static NSString *const key = @"CFBundleShortVersionString";

+ (instancetype)guideView{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
}


- (IBAction)onClickIknow {
    [self removeFromSuperview];
}

+ (void)show{
    NSString *newVer = [NSBundle mainBundle].infoDictionary[key];
    
    NSString *oldVer =[[NSUserDefaults standardUserDefaults] stringForKey:key];
    
    if (![newVer isEqualToString:oldVer]) {
        FWGuideView *guideView = [FWGuideView guideView];
        UIWindow *window = [UIApplication sharedApplication].keyWindow;
        guideView.frame = window.bounds;
        [window addSubview:guideView];
        [[NSUserDefaults standardUserDefaults] setObject:newVer forKey:key];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

}

@end
